(function () {
    var serverData = {};
    var serverTable;
    //查询
    jQuery('#search_btn').on('click',function(){
        serverData.key=jQuery('#search').val();
        serverTable.draw();
    })
    //撤销查询
    jQuery('#reset').on("click",function()
    {
        jQuery('#search').val('');
        serverData.key ='';
        serverTable.draw();
    });
    
    jQuery(document).ready(function () {
        serverTable = jQuery('#dataTable').DataTable({
        	"serverSide": true,
        	"ordering": false,
        	"ajax": {
        		"dataType": "json",
        		"type": "get",
        		"cache": false,
        		"url":window.rootPath+ '/ui/payRegulationAgingAccount/getFirst',
        		"data": function (d) {
        			return $.extend({}, d, serverData);
        		}
        	},
            "columns" : [{
                            data : null,
                            defaultContent : ""// 排序   1
                        },                       
        	            {
        	                data: 'orderUnit'
        	                
        	            },
        	            {
        	                data: 'nSecondStep'
        	                
        	            },
        	            {
       		        	 	data: 'nRSecondStep'
        	            },
        	            {
        	                data: 'nThreeStep'
        	                
        	            },
        	            {
        	                data: 'nRThreeStep'
        	                
        	            },
        	            {
        	                data: 'nFourStep'
        	                
        	            },
        	            {
        	                data: 'nRFourStep'
        	                
        	            },
        	            {
        	                data: 'nFiveStep'
        	            },
        	            {
        	                data: 'nRFiveStep'
        	            },
        	            {
        	                data: 'nSixStep'
        	            },
        	            {
        	                data: 'nRSixStep'
        	            },
        	            {
        	                data: 'nSevenStep'
        	            },
        	            {
        	                data: 'nRSevenStep'
        	            },
        	            {
        	                data: 'nEeightStep'
        	            },
        	            {
        	                data: 'nREeightStep'
        	            },
        	            {
        	                data: 'nNineStep'
        	            },
        	            {
        	                data: 'nRNineStep'
        	            }],
            "drawCallback": function (oSettings) {
                var k = 0;
                var total = oSettings.aiDisplay.length + oSettings._iDisplayStart;

                for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
                    $('td:eq(0)', oSettings.aoData[oSettings.aiDisplay[k]].nTr).text(i + 1);
                    k++;
                }
            }
        });
        /**
         * 	获取当年当月和当部门
         * */
        var now= new Date();
  	  	var year=now.getFullYear();
  	  	var month=now.getMonth();
  	  	var url=window.rootPath+ '/ui/payRegulationAgingAccount/getmypage';
  	  	$.ajax({
  	         async: false,
  	         url: url,
  	         dataType: 'json',
  	         success: function (json) {
  	        	 document.getElementById("nianyue").innerHTML=year+"年"+json.superior+(month+1)+"月销售应收帐款帐龄台帐";
  	        }
  	  });
    });
})();

  